package com.victor.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.victor.entity.Advertisement;

@Mapper
public interface AdvertisementDao {

	/**
	 * 查询列表
	 * 
	 * @return
	 */
	@Select({ "select * from advertisement order by id desc" })
	List<Advertisement> getAll();

	/**
	 * 查详情询
	 * 
	 * @param aid
	 * @return
	 */
	@Select({ "select * from advertisement where id=#{aid}" })
	Advertisement findByid(@Param("aid") int aid);

	/**
	 * 新建
	 * 
	 * @param advertisement
	 * @return
	 */
	@Insert({ "insert into advertisement (title,photo,submittime,content) values (#{title},#{photo},now(),#{content})" })
	int insert(Advertisement advertisement);

	/**
	 * 修改
	 * 
	 * @param advertisement
	 * @return
	 */
	int update(Advertisement advertisement);

	/**
	 * 批量删除
	 * 
	 * @param ids
	 * @return
	 */
	int batchDelete(@Param("ids") int[] ids);

	/**
	 * 查询列表(日期查询)
	 * 
	 * @param starttime
	 * @param endtime
	 * @return
	 */
//	@Select({ "SELECT * FROM advertisement WHERE submittime BETWEEN #{starttime} AND #{endtime}" })
	List<Advertisement> getAdBySearch(@Param("starttime") String starttime, @Param("endtime") String endtime,@Param("tiaojian") String tiaojian);

}
